package com.xiaoyu.studyworkspace.controller;

import com.xiaoyu.studyworkspace.common.util.Result;
import com.xiaoyu.studyworkspace.dto.MethodNameDTO;
import com.xiaoyu.studyworkspace.dto.PredictionDTO;
import com.xiaoyu.studyworkspace.pojo.MethodName;
import com.xiaoyu.studyworkspace.service.PredictionService;
import com.xiaoyu.studyworkspace.vo.PredictionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/prediction")
@Slf4j
@CrossOrigin("*")
public class PredictionController {

    @Autowired
    private PredictionService predictionService;

    @GetMapping
    public Result getMethodByName(PredictionDTO predictionDTO) {
        PredictionVO predictionVo = predictionService.getMethodByName(predictionDTO);
        Result<PredictionVO> success = Result.success(predictionVo, "成功!");
        return success;
    }


    @GetMapping("/name")
    public Result getAllMethodName(MethodNameDTO methodNameDTO) {
        List<MethodName> methodNameList = predictionService.getAllMethodNameById(methodNameDTO);
        Result<List<MethodName>> success = Result.success(methodNameList, "成功!");
        return success;
    }
}
